package com.github.baichuan.application.scaffold.dto.membership;

import com.github.baichuan.application.scaffold.domain.application.Application;
import com.github.baichuan.application.scaffold.domain.identity.ApplicationMember;
import com.github.baichuan.application.scaffold.jpa.identity.ApplicationMemberSpecification;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

@Schema(title = "用户查询条件")
@Getter
@Setter
public class ApplicationMemberQueryCriteria {

    @Schema(title = "用户类型")
    private String memberType;

    @Schema(title = "登陆名/姓名/手机/邮箱")
    private String keyword;

    @Schema(title = "角色")
    private Short roleId;

    @Schema(title = "所属机构")
    private String orgBranch;

    public ApplicationMemberSpecification specification(@NonNull Application application, @NonNull ApplicationMember applicationMember) {
        return ApplicationMemberSpecification.builder()
                .application(application)
                .applicationMember(applicationMember)
                .memberType(memberType)
                .keyword(keyword)
                .roleId(roleId)
                .orgBranch(orgBranch)
                .build();
    }
}
